package com.thibal.lylo;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class HelpWindowAdapter extends BaseAdapter {
	
	private final Context context;
	private ArrayList<Style> list;

	public HelpWindowAdapter(Context context, ArrayList<Style> listArg) {
		this.context = context;
		list = listArg;
		
	}
	
	@Override
	public int getCount() {
		return list == null ? 0 : list.size();
	}

	@Override
	public Object getItem(int index) {
		return list == null ? null : list.get(index);
	}

	@Override
	public long getItemId(int index) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView;
		
		Style style = list.get(position);

		
		if (convertView != null) {
			rowView = convertView;
		} else {
			// Get a new instance of the row layout view
			rowView = View.inflate(context, R.layout.help_window_row, null);
		}
		
		TextView text = (TextView) rowView.findViewById(R.id.textViewStyle);
		ImageView styleIV = (ImageView) rowView.findViewById(R.id.imageViewStyle);
		
		text.setText(style.getStyle());
		styleIV.setImageResource(style.getResoureID());

		return rowView;
	}
}
